package com.sense.kukoo.common.wiget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.sense.kukoo.common.R;
import com.sense.kukoo.common.utils.ApplicationContext;
import com.sense.kukoo.lib_picture.loader.Monet;

public class MusicCollectionItemView extends FrameLayout {

    private ImageView iv_music_icon;
    private TextView tv_music_type;
    private TextView tv_music_des;
    private TextView tv_music_msg;
    private View root;

    public MusicCollectionItemView(@NonNull Context context) {
        super(context);
        initView();
    }

    public MusicCollectionItemView(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        initView();
    }

    public MusicCollectionItemView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView();
    }

    public MusicCollectionItemView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        initView();
    }

    private void initView(){
        LayoutInflater.from(getContext()).inflate(R.layout.common_music_collection_item, this, true);
        //
        root = findViewById(R.id.root);
        iv_music_icon = findViewById(R.id.iv_music_icon);
        tv_music_type = findViewById(R.id.tv_music_type);
        tv_music_des = findViewById(R.id.tv_music_collection);
        tv_music_msg = findViewById(R.id.tv_music_msg);
    }

    public void setIconUrl(String url){
        Monet.get(ApplicationContext.instance())
                .load(url)
                .placeholder(R.mipmap.common_icon_default_editor_picks)
                .into(iv_music_icon);
    }

    public void setType(String s){
        tv_music_type.setText(s);
    }

    public void setDes(String s){
        tv_music_des.setText(s);
    }

    public void setMsg(String s){
        tv_music_msg.setText(s);
    }

    public void setItemClickListener(OnClickListener l){
        root.setOnClickListener(l);
    }
}
